<?php
/*
 * @Author: 杨红兵 
 * @Date: 2022-07-30 14:38:17 
 * @Last Modified by: 杨红兵
 * @Last Modified time: 2022-08-02 16:27:25
 */

namespace app\libraries\utils\tokencheck;

use app\libraries\abstract\token\TokenAbstract;
use think\Manager;

class TokenCheckCall extends Manager
{
    /**
     * 驱动提供命名空间
     *
     * @var string
     * @Author YangHB
     * @DateTime 2022-07-30 16:03:39
     *
     */
    protected $namespace = "\\app\\libraries\\utils\\tokencheck\\";

    /**
     * 默认驱动
     * @return string|null
     */
    public function getDefaultDriver()
    {
        return $this->app->config->get('token_check.driver', '');
    }

    /**
     * 重写返回配置
     *
     * @Author YangHB
     * @DateTime 2022-07-30 17:53:58
     *
     * @param string $name
     * @return array
     */
    protected function resolveConfig(string $name)
    {
        return (array)$this->app->config->get("token_check.drivers.{$name}", []);
    }

    /**
     * 获取驱动类型
     * @param string $name
     * @return mixed
     */
    protected function resolveType(string $name)
    {
        return $this->resolveConfig($name)['type'] ?? '';
    }

    /**
     * 获取指定驱动
     *
     * @Author YangHB
     * @DateTime 2022-07-30 20:04:42
     *
     * @param string $name
     * @return TokenAbstract
     */
    public function client(string $name): TokenAbstract
    {
        return parent::driver($name);
    }
}
